Namespace DataStream
    <Serializable(), ObfuscationAttribute(Exclude:=True, ApplyToMembers:=True)> _
    Public Class StreamControlSetting
        Implements IComparable(Of StreamControlSetting), IComparable

        Private mName As String = ""
        Private mColour As Color = Color.Black
        Private mVisible As Boolean = False
        Private mAlarmLowLimit As Double = -1
        Private mAlarmHighLimit As Double = -1

        Sub New(ByVal Name As String, ByVal Colour As Color, Optional ByVal Visible As Boolean = False)
            If Name = "" Then
                Throw New ArgumentException("Name cannot be a NULL string")
            End If
            mName = Name
            mColour = Colour
            mVisible = Visible
        End Sub

        ''' <summary>
        ''' Name of the graph setting. Usualy the name of the graph item
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public ReadOnly Property Name() As String
            Get
                Return mName
            End Get
        End Property

        ''' <summary>
        ''' Colour to use to display in the graph
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Colour() As Color
            Get
                Return mColour
            End Get
            Set(ByVal value As Color)
                mColour = value
            End Set
        End Property

        ''' <summary>
        ''' Determines if the item is visible
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Overridable Property Visible() As Boolean
            Get
                Return mVisible
            End Get
            Set(ByVal value As Boolean)
                mVisible = value
            End Set
        End Property

        Public Function CompareTo(ByVal other As StreamControlSetting) As Integer Implements System.IComparable(Of StreamControlSetting).CompareTo
            If Me.Visible And other.Visible Then
                If Me.Name > other.Name Then
                    Return -1
                Else
                    Return 1
                End If
            ElseIf Not (Me.Visible = False Xor other.Visible = False) Then
                If Me.Name > other.Name Then
                    Return -1
                Else
                    Return 1
                End If
            Else
                If Me.Visible Then
                    Return 1
                ElseIf other.Visible Then
                    Return -1
                End If
            End If
        End Function

        Public Function CompareTo1(ByVal obj As Object) As Integer Implements System.IComparable.CompareTo
            Dim other As StreamControlSetting = CType(obj, StreamControlSetting)

            Return Me.CompareTo(other)
        End Function
    End Class
End Namespace

